//
//  HZUserCaseManageTableViewCell.m
//  MyDoctor
//
//  Created by 徐彩东 on 16/5/5.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZUserCaseManageTableViewCell.h"

@interface HZUserCaseManageTableViewCell ()

///  上面点
@property (nonatomic , strong ) UIImageView *pointTopImg;

///  下面点
@property (nonatomic , strong ) UIImageView *pointButtomImg;

///  线
@property (nonatomic , strong ) UIImageView *lineImg;

///  时间
@property (nonatomic , strong ) UILabel *timeLabel;

///  病例照片
@property (nonatomic , strong ) UIImageView *iconImg;

///  疾病类型
@property (nonatomic , strong ) UILabel *illnessTypeLabel;

///  疾病描述
@property (nonatomic , strong ) UILabel *illnessDescribeLabel;

///  记录约束
@property (nonatomic , strong ) MASConstraint *constraint;
@end

@implementation HZUserCaseManageTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //设置界面
        [self setupUI];
    }
    return self;
}

#pragma mark - 设置界面
-(void)setupUI{

    //添加子控件
    [self.contentView addSubview:self.pointButtomImg];
    [self.contentView addSubview:self.pointTopImg];
    [self.contentView addSubview:self.lineImg];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.iconImg];
    [self.contentView addSubview:self.illnessTypeLabel];
    [self.contentView addSubview:self.illnessDescribeLabel];
    
    
    //约束
    [self.pointTopImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self).offset(10);
        make.top.equalTo(self);
        make.width.height.equalTo(@15);
    }];
    
    [self.pointButtomImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self).offset(10);
        make.bottom.equalTo(self);
        make.width.height.equalTo(@15);
    }];
    
    [self.lineImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.pointTopImg);
       self.constraint = make.top.equalTo(self.pointTopImg.mas_bottom);
        make.bottom.equalTo(self.pointButtomImg.mas_top);
        make.width.equalTo(@1);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.left.equalTo(self.pointTopImg.mas_right).offset(10);
    }];
    
    [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeLabel);
        make.top.equalTo(self.timeLabel.bottom).equalTo(5);
        make.width.height.equalTo(@60);
    }];
    
    [self.illnessTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImg.mas_right).offset(10);
        make.top.equalTo(self.iconImg);
    }];
    
    [self.illnessDescribeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.illnessTypeLabel);
        make.top.equalTo(self.illnessTypeLabel.mas_bottom).offset(10);
        make.bottom.equalTo(self.iconImg);
        make.right.equalTo(self).offset(-20);
    }];
    
}

#pragma mark - 是否隐藏下面的原点
-(void)isPointButtom:(BOOL)isPoint WithReload:(void (^)())reloadBlock{

    //隐藏下面的原点
    self.pointTopImg.hidden = YES;
    
    //清除约束
    [self.constraint uninstall];
    //更新约束
    [self.lineImg mas_updateConstraints:^(MASConstraintMaker *make) {
       self.constraint = make.top.equalTo(self);
    }];
}

#pragma mark - 懒加载
-(UIImageView *)pointButtomImg{

    if (!_pointButtomImg) {
        
        _pointButtomImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"illness_rb_img_sel.png"]];
    }
    return _pointButtomImg;
}

-(UIImageView *)pointTopImg{
    
    if (!_pointTopImg) {
        
        _pointTopImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"illness_rb_img_sel.png"]];
    }
    
    return _pointTopImg;
    
}

-(UIImageView *)lineImg{

    if (!_lineImg) {
        
        _lineImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"illness_img_line.png"]];
    }
    return _lineImg;
}

-(UILabel *)timeLabel{

    if (!_timeLabel) {
        
        _timeLabel = [[UILabel alloc]initWithTitle:@"16-05-05 16:39:29" WitthTextFont:12 WithTextColor:[UIColor lightGrayColor]];
    }
    return _timeLabel;
}

-(UIImageView *)iconImg{

    if (!_iconImg) {
        
        _iconImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"name"]];
    }
    return _iconImg;
}

-(UILabel *)illnessTypeLabel{

    if (!_illnessTypeLabel) {

        _illnessTypeLabel = [[UILabel alloc]initWithTitle:@"我没有病，活着好好的哈哈" WitthTextFont:13 WithTextColor:[UIColor blackColor]];
        
    }
    return _illnessTypeLabel;
}

-(UILabel *)illnessDescribeLabel{

    if (!_illnessDescribeLabel) {
        
        _illnessDescribeLabel = [[UILabel alloc]initWithTitle:@"这是病例描述" WitthTextFont:12 WithTextColor:[UIColor lightGrayColor]];
        
        _illnessDescribeLabel.numberOfLines = 2;
    }
    return _illnessDescribeLabel;
}

@end






























